package entity;

import com.alibaba.fastjson.annotation.JSONField;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Created By zby on 10:28 2019/6/27
 * 客户类型
 */
public enum CustomerTypeEnum {

    CUSTOMER_TYPE_ENTERPRISE("企业", "描述企业"),
    CUSTOMER_TYPE_INSTITUTIONS("事业", "描述事业"),
    CUSTOMER_TYPE_TEAM("团队", "描述团队"),
    CUSTOMER_TYPE_PERSONAL("个人", "描述个人");

    /**
     * 展示中文表述
     */
    @JSONField
    private String title;

    private String desc;

    CustomerTypeEnum(String title, String desc) {
        this.title = title;
        this.desc = desc;
    }

    /**
     * 根据枚举名称获取枚举
     *
     * @param enumName 枚举名称
     * @return AuctionTypeEnum        对应的枚举值
     */
    public static CustomerTypeEnum getByEnumName(final String enumName) {
        for (CustomerTypeEnum element : values()) {
            if (element.name().equals(enumName)) {
                return element;
            }
        }
        return null;
    }

    /**
     * 获取枚举名称和title所有的映射
     *
     * @return
     */
    public static Map<String, String> getName2TitleMap() {

        Map<String, String> name2TitleMap = new LinkedHashMap<>();

        for (CustomerTypeEnum element : values()) {
            name2TitleMap.put(element.name(), element.title);
        }

        return name2TitleMap;
    }

    public String getTitle() {
        return this.title;
    }

    public String getDesc() {
        return desc;
    }
}
